<?        
        require_once('../inc/models/products_model.php');
        if(isset($_POST['id']))
        {
                $row = $_POST;
                SaveProduct($row);
                header("Location: index.php");
		}
		else 
		{
			    $row = GetProduct($_REQUEST['id']);
				$category = GetProductKeywords();				
        }
?>
<!DOCTYPE html>
<html lang="en">
        <?php include('../inc/header.php'); ?>
        <body>
        <?php include('../inc/navigation.php'); ?>
        <div class="span9">
        	<div class="row-fluid">
            	<h2>Edit Product</h2>                       
				<form class="form-horizontal" method="post" action="">
                	<input type="hidden" name="id" value="<?=$_GET['id']?>" />
                    <div class=" control-group">
                		<label class="control-label" for="product_category">Product Category:</label>
                    	<div class="controls">
                     		<select name="product_category" id = "product_category">
                       			<? while($rs = $category->fetch_assoc()): ?>
                       				<option value="<?=$rs['id']?>"><?=$rs['Value']?></option>
                       			<?php endwhile; ?>                        		                    		
                       		</select>                        	                            	
	                    </div>
	                </div>   
	                <div class=" control-group">
	               		<label class="control-label" for="name">Product Name:</label>
		                <div class="controls">                        	
							<input type="text" name="product_name" id="product_name" value = "<?=$row['name']?>" />
						</div>
				    </div>                   
				    <div class=" control-group">
	               		<label class="control-label" for="price">Price:</label>
		                <div class="controls">                        	
							<input type="text" name="price" id="price" value = "<?=$row['price']?>" />
						</div>
				    </div>  
				    <div class=" control-group">
	                	<label class="control-label" for="weight">Weight(in pounds):</label>
	                    <div class="controls">                        	
							<input type="text" name="weight" id="weight" value = "<?=$row['weight']?>" />
						</div>
					</div> 
					<div class=" control-group">
	                	<label class="control-label" for="stock">Stock:</label>
	                    <div class="controls">                        	
							<input type="text" name="stock" id="stock" value = "<?=$row['stock']?>" />
						</div>
					</div>                         
					<input type="submit" name="submit" value="Save" />
                </form>
        	</div>
    	</div>
    	<!-- All Bootstrap JavaScript Files -->
       <script src="../inc/bootstrap/js/jquery.js"></script>
       <script src="../inc/bootstrap/js/bootstrap.js"></script>
	</body>
</html>